//------------------------------------------------------------------------------ 
//      Copyright (c) 2004-2009, Be Nanashi-San 
// 
//      Permission is hereby granted, free of charge, to any person obtaining a 
//      copy of this software and associated documentation files (the "Software"), 
//      to deal in the Software without restriction, including without limitation 
//      the rights to use, copy, modify, merge, publish, distribute, sublicense, 
//      and/or sell copies of the Software, and to permit persons to whom the 
//      Software is furnished to do so, subject to the following conditions: 
// 
//      The above copyright notice and this permission notice shall be included in 
//      all copies or substantial portions of the Software. 
// 
//      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
//      IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
//      FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
//      AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
//      LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
//      FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
//      DEALINGS IN THE SOFTWARE. 
// 
//      File Name:   StatusView.cpp
//      Author:      Be Nanashi-San 
//      Description: Status Bar	 
//------------------------------------------------------------------------------

#include <Bitmap.h>
#include <Rect.h>
#include <PictureButton.h>
#include <Messenger.h>
#include <MenuBar.h>
#include <MenuItem.h>
#include <Window.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <LayoutBuilder.h>
#include <GroupView.h>
#include <StringView.h>

#include "messages.h"
#include "StatusBarView.h"
#include "2chPositive.h"
#include "setting.h"

//Image translated by QuickRes (copy as text)
static const int32 kImageWidth = 27;
static const int32 kImageHeight = 13;

static const unsigned char kOnLineImageBits[] = {
	0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 
	0x3f, 0x3f, 0x3f, 0x3f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x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x1b, 
	0x1b, 0x1b, 0x3f, 0x3f, 0x10, 0x1b, 0x1b, 0x1b, 0x1b, 0x00, 0xb0, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 
	0x00, 0xb0, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x1b, 0x1b, 0x3f, 0x3f, 
	0x10, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 
	0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f
};


////////////////////////////////////////////////////////////////////////////////
// StatusBarView
//
//
////////////////////////////////////////////////////////////////////////////////
StatusBarView::StatusBarView()
:BGroupView()
{
}
////////////////////////////////////////////////////////////////////////////////
// ~StatusBarView
//
//
////////////////////////////////////////////////////////////////////////////////
StatusBarView::~StatusBarView()
{
}
////////////////////////////////////////////////////////////////////////////////
// MakePicture
//
//
////////////////////////////////////////////////////////////////////////////////
static BPicture *
MakePicture(BView *view, const unsigned char *data, size_t size)
{
	view->BeginPicture(new BPicture);
	BBitmap *map = new BBitmap(view->Bounds(), B_CMAP8);
	map->SetBits(data, size, 0, B_CMAP8);
	view->DrawBitmapAsync(map);
	return view->EndPicture();
}
////////////////////////////////////////////////////////////////////////////////
// AttachedToWindow
//
//
////////////////////////////////////////////////////////////////////////////////
void	
StatusBarView::AttachedToWindow()
{
	this->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	BRect r(0, 0, kImageWidth - 1, kImageHeight - 1);
	BView *someView = new BView(r, "", B_FOLLOW_NONE, B_WILL_DRAW);
	this->AddChild(someView);
	//オフライン／オンラインボタン
	BPicture *pic = MakePicture(someView, kOnLineImageBits, sizeof(kOnLineImageBits));
	BPicture *pic2 = MakePicture(someView, kOffLineImageBits, sizeof(kOffLineImageBits));
	fOnOffButton = new BPictureButton(r, "", pic, pic2, new BMessage(kMEG_ONOFF_BUTTON), B_TWO_STATE_BUTTON, B_FOLLOW_LEFT);
	fOnOffButton->SetTarget(this);
	fOnOffButton->SetExplicitMaxSize(BSize(kImageWidth,kImageHeight));

	if(theSettings().GetBool(kSETTING_OFFLINE)) //offline
		fOnOffButton->SetValue(B_CONTROL_ON);
	else //online
		fOnOffButton->SetValue(B_CONTROL_OFF);
	
	//書き込みボタン
	pic = MakePicture(someView, kWritingImage01Bits, sizeof(kWritingImage01Bits));
	pic2 = MakePicture(someView, kWritingImage02Bits, sizeof(kWritingImage02Bits));
	fWriteButton = new BPictureButton(r, "", pic, pic2, new BMessage(kMEG_WRITE_BUTTON), B_ONE_STATE_BUTTON, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fWriteButton->SetTarget(this->Window());
	fWriteButton->SetExplicitMaxSize(BSize(kImageWidth,kImageHeight));
	fText = new BStringView("","2chPositiveへようこそ！");
	this->RemoveChild(someView);
	delete someView;

	BLayoutBuilder::Group<>(this)
			.AddGroup(B_HORIZONTAL, 2.0f)
			.Add(fOnOffButton)
			.Add(fWriteButton)
			.Add(fText)
			.AddGlue()
			.End();
}
////////////////////////////////////////////////////////////////////////////////
// MessageReceived
//
//
////////////////////////////////////////////////////////////////////////////////
void
StatusBarView::MessageReceived(BMessage *message)
{
	switch(message->what){
	case kMSG_STATUS_MESSAGE:
	{
		const char *text;
		message->FindString("message", &text);
		fText->SetText(text);
		this->Draw(this->Bounds());
		break;
	}
	case kMEG_ONOFF_BUTTON:
		this->DoOnOff(false);
		break;

	case kMENU_FILE_OFFLINE:
		this->DoOnOff(true);
		break;
		
	default:
		BView::MessageReceived(message);
		break;
	}

}
////////////////////////////////////////////////////////////////////////////////
// DoOnOff
// オンライン／オフラインの切換。
//
////////////////////////////////////////////////////////////////////////////////
void
StatusBarView::DoOnOff(bool setButton)
{
	bool mode = theSettings().GetBool(kSETTING_OFFLINE) == kONLINE ? kOFFLINE : kONLINE;
	theSettings().SetBool(kSETTING_OFFLINE, mode);
	BMenuBar *mbar = this->Window()->KeyMenuBar();
	BMenuItem *item = mbar->SubmenuAt(0)->FindItem("オフライン");
	item->SetMarked(mode);		

	if(!setButton) return;

	if(mode) //offline
			fOnOffButton->SetValue(B_CONTROL_ON);
	else //online
			fOnOffButton->SetValue(B_CONTROL_OFF);
}

////////////////////////////////////////////////////////////////////////////////
// Draw
//
//
////////////////////////////////////////////////////////////////////////////////
void
StatusBarView::Draw(BRect updateRect)
{
	BRect rect = this->Bounds();

//	this->SetHighColor(ui_color(B_MENU_BACKGROUND_COLOR));
//	FillRect(updateRect);
//	this->SetHighColor(125,125,125);
//	this->StrokeLine(BPoint(rect.left, 0), BPoint(rect.right, 0));	
//	this->SetHighColor(255, 255, 255);
//	this->StrokeLine(BPoint(rect.left, 1), BPoint(rect.right, 1));	
//	if(!fText.Length()) return;
//	this->SetHighColor(0, 0, 0);

}

